import java.util.Arrays;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class H {
    public int hIndex(int[] citations) {
        int len = citations.length;
        Arrays.sort(citations);
        int count = 0;
        int result = 0;
        for (int i = len/2; i < len; i++) {
            int temp = citations[i];
            for (int j = i; j < len; j++){
                if (citations[j]>=temp){
                    count++;
                }
            }
            if (count>result){
                result = citations[i];
            }
            count = 0;
        }
        return result;
    }
//    public int hIndex(int[] citations) {
//        Arrays.sort(citations);
//        int h = 0, i = citations.length - 1;
//        while (i >= 0 && citations[i] > h) {
//            h++;
//            i--;
//        }
//        return h;
//    }
}
